/**
 * Created by Administrator on 2017/8/2.
 */

$(document).ready(function () {

    if (C.token==undefined||C.token==null){
        alert('请登录');
        againLogin();
        //location.href='login.html';
        return ;
    }

    $('.opinion-submit').bind('click',goSubmit);
    function goSubmit() {
        var content=$('#opinion-back').val();

        if (content==null||content==''){
            alert('小主，你没输内容阿....');
            return false;
        }else {
            $.ajax({
                url:C.interface.opinion,
                type:'post',
                dataType:'json',
                data:{
                    content:content,
                    token:C.token
                },
                success:function (response) {
                    if (response.result=='success'){
                        dialog.optionSuccess('提交成功');
                        content='';
                        setTimeout(function () {
                            history.go(-1);
                        },2000);

                    }else if (response.result=='login'){
                        alert('登录过期请重新登录');
                        againLogin();

                    }else {
                        alert(response.errorMsg);
                    }
                },
                error:function (response) {
                    alert(response.errorMsg);
                }

            })
        }

    }
});